// SelectUser.cpp : implementation file
//

#include "stdafx.h"
#include "calendar.h"
#include "SelectUser.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSelectUser dialog


CSelectUser::CSelectUser(CWnd* pParent /*=NULL*/)
	: CDialog(CSelectUser::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSelectUser)
	m_szPassword = _T("");
	//}}AFX_DATA_INIT
	m_szUserName = _T("");
}


void CSelectUser::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSelectUser)
	DDX_Control(pDX, IDOK, m_btnOk);
	DDX_Control(pDX, IDC_COMBO1, m_cbUsers);
	DDX_Text(pDX, IDC_PASSWORD, m_szPassword);
	DDV_MaxChars(pDX, m_szPassword, 10);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSelectUser, CDialog)
	//{{AFX_MSG_MAP(CSelectUser)
	ON_EN_CHANGE(IDC_PASSWORD, OnChangeUser)
	ON_CBN_SELCHANGE(IDC_COMBO1, OnChangeUser)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSelectUser message handlers

BOOL CSelectUser::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	if( m_saUserName.GetSize() < 0 ) 
		DestroyWindow();
	else
		for( int i = 0; i < m_saUserName.GetSize(); i++) {
			m_cbUsers.AddString(m_saUserName[i]);
		}
	m_cbUsers.SetCurSel(0);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSelectUser::OnOK() 
{
	m_cbUsers.GetLBText( m_cbUsers.GetCurSel(), m_szUserName );
	
	CDialog::OnOK();
}

void CSelectUser::OnChangeUser() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

	if( m_cbUsers.GetCurSel() < 0 || m_szPassword.IsEmpty())
		m_btnOk.EnableWindow(FALSE);
	else
		m_btnOk.EnableWindow(TRUE);
}
